// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.characters.professions;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Stack;
import zombie.characters.skills.PerkFactory;
import zombie.core.textures.Texture;
import zombie.debug.DebugLog;
import zombie.interfaces.IListBoxItem;

public final class ProfessionFactory {
    public static LinkedHashMap<String, ProfessionFactory.Profession> ProfessionMap = new LinkedHashMap();

    public static void init() {
    }

    public static ProfessionFactory.Profession addProfession(String type, String name, String IconPath, int points) {
        ProfessionFactory.Profession profession = new ProfessionFactory.Profession(type, name, IconPath, points, "");
        ProfessionMap.put(type, profession);
        return profession;
    }

    public static ProfessionFactory.Profession getProfession(String type) {
        for (ProfessionFactory.Profession profession : ProfessionMap.values()) {
            if (profession.type.equals(type)) {
                return profession;
            }
        }

        return null;
    }

    public static ArrayList<ProfessionFactory.Profession> getProfessions() {
        ArrayList arrayList = new ArrayList();

        for (ProfessionFactory.Profession profession : ProfessionMap.values()) {
            arrayList.add(profession);
        }

        return arrayList;
    }

    public static void Reset() {
        ProfessionMap.clear();
    }

    public static class Profession implements IListBoxItem {
        public String type;
        public String name;
        public int cost;
        public String description;
        public String IconPath;
        public Texture texture = null;
        public Stack<String> FreeTraitStack = new Stack();
        private List<String> freeRecipes = new ArrayList();
        public HashMap<PerkFactory.Perk, Integer> XPBoostMap = new HashMap();

        public Profession(String _type, String _name, String IconPathname, int _cost, String desc) {
            this.type = _type;
            this.name = _name;
            this.IconPath = IconPathname;
            if (!IconPathname.equals("")) {
                this.texture = Texture.trygetTexture(IconPathname);
            }

            this.cost = _cost;
            this.description = desc;
        }

        public Texture getTexture() {
            return this.texture;
        }

        public void addFreeTrait(String trait) {
            this.FreeTraitStack.add(trait);
        }

        public ArrayList<String> getFreeTraits() {
            ArrayList arrayList = new ArrayList();
            arrayList.addAll(this.FreeTraitStack);
            return arrayList;
        }

        @Override
        public String getLabel() {
            return this.getName();
        }

        public String getIconPath() {
            return this.IconPath;
        }

        @Override
        public String getLeftLabel() {
            return this.getName();
        }

        @Override
        public String getRightLabel() {
            int _int = this.getCost();
            if (_int == 0) {
                return "";
            } else {
                String string = "+";
                if (_int > 0) {
                    string = "-";
                } else if (_int == 0) {
                    string = "";
                }

                if (_int < 0) {
                    _int = -_int;
                }

                return string + _int;
            }
        }

        public String getType() {
            return this.type;
        }

        public void setType(String _type) {
            this.type = _type;
        }

        public String getName() {
            return this.name;
        }

        public void setName(String _name) {
            this.name = _name;
        }

        public int getCost() {
            return this.cost;
        }

        public void setCost(int _cost) {
            this.cost = _cost;
        }

        public String getDescription() {
            return this.description;
        }

        public void setDescription(String _description) {
            this.description = _description;
        }

        public void setIconPath(String _IconPath) {
            this.IconPath = _IconPath;
        }

        public Stack<String> getFreeTraitStack() {
            return this.FreeTraitStack;
        }

        public void addXPBoost(PerkFactory.Perk perk, int level) {
            if (perk != null && perk != PerkFactory.Perks.None && perk != PerkFactory.Perks.MAX) {
                this.XPBoostMap.put(perk, level);
            } else {
                DebugLog.General.warn("invalid perk passed to Profession.addXPBoost profession=%s perk=%s", this.name, perk);
            }
        }

        public HashMap<PerkFactory.Perk, Integer> getXPBoostMap() {
            return this.XPBoostMap;
        }

        public void setFreeTraitStack(Stack<String> _FreeTraitStack) {
            this.FreeTraitStack = _FreeTraitStack;
        }

        public List<String> getFreeRecipes() {
            return this.freeRecipes;
        }

        public void setFreeRecipes(List<String> _freeRecipes) {
            this.freeRecipes = _freeRecipes;
        }
    }
}
